﻿using System;
using System.Text;
using System.Text.RegularExpressions;
using System.Web;
using AnyOffice.Components;
using AnyOffice.DAL;
using AnyOffice.Model;
namespace AnyOffice.general.system.workflow.flow_form
{
     public partial class cool_submit : ModulePage
    {       

        protected void Page_Load(object sender, EventArgs e)
        {
            Match match;
            int num = int.Parse((Request.Form["FORM_ID"] != null) ? Request.Form["FORM_ID"].ToString() : "0");
            string str = (Request.Form["CONTENT"] != null) ? Request.Form["CONTENT"].ToString() : "";
            int num2 = int.Parse((Request.Form["CLOSE_FLAG"] != null) ? Request.Form["CLOSE_FLAG"].ToString() : "0");
            string input = str;
            int startIndex = 0;
            StringBuilder builder = new StringBuilder();
            string pattern = "<(?<Tag>IMG)[^>]*?class=DATE[^>]*?\\stitle=(?:(?<Title>[^\\s\"'>]+)|(?:\"(?<Title>.*?)\")|(?:\\'(?<Title>.*)\\'))[^>]*?\\ssrc=(?:(?<src>[^\\s\"'>]+)|(?<src>\\w+)|\"(?<src>.*?)\"|\\'(?<src>.*?)\\')[^>]*?>";
            Regex regex = new Regex(pattern, RegexOptions.Compiled | RegexOptions.IgnoreCase);
            for (match = regex.Match(input); match.Success; match = match.NextMatch())
            {
                if (match.Groups["src"].Success)
                {
                    builder.Append(input.Substring(startIndex, match.Groups["src"].Index - startIndex));
                    builder.Append("/images/form/calendar.gif");
                    startIndex = match.Groups["src"].Index + match.Groups["src"].Length;
                }
            }
            builder.Append(input.Substring(startIndex));
            input = builder.ToString();
            startIndex = 0;
            builder = new StringBuilder();
            pattern = "<(?<Tag>IMG)[^>]*?class=LIST_VIEW[^>]*?\\stitle=(?:(?<Title>[^\\s\"'>]+)|(?:\"(?<Title>.*?)\")|(?:\\'(?<Title>.*)\\'))[^>]*?\\ssrc=(?:(?<src>[^\\s\"'>]+)|(?<src>\\w+)|\"(?<src>.*?)\"|\\'(?<src>.*?)\\')[^>]*?>";
            regex = new Regex(pattern, RegexOptions.Compiled | RegexOptions.IgnoreCase);
            for (match = regex.Match(input); match.Success; match = match.NextMatch())
            {
                if (match.Groups["src"].Success)
                {
                    builder.Append(input.Substring(startIndex, match.Groups["src"].Index - startIndex));
                    builder.Append("/images/form/listview.gif");
                    startIndex = match.Groups["src"].Index + match.Groups["src"].Length;
                }
            }
            builder.Append(input.Substring(startIndex));
            str = builder.ToString();
            FlowFormTypeDao dao = new FlowFormTypeDao();
            FlowFormTypeData ollO = new FlowFormTypeData();
            ollO.FormId = num;
            ollO.FormModel = str;
            dao.UpdateModel(base.Conn, ollO);
            if (num2 == 1)
            {
                Response.Write("<script>window.close();</script>");
            }
            else
            {
                base.CloseConn();
                Response.Redirect("form_cool.aspx?form_id=" + num.ToString() + "&save=1");
            }
        }
  
    }
}

